package com.chinatelecom.telecollege.sellerrewarding.controller;

import com.chinatelecom.telecollege.sellerrewarding.Entity.sellorder;
import com.chinatelecom.telecollege.sellerrewarding.service.sellorderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by lenovo on 2017/6/21.
 */
@RestController
public class sellorderController {
    @Autowired
    private sellorderService sellorderService;

    @RequestMapping(value = "/sellorder")
    public sellorder querysellorder(@RequestParam int id) {
        return sellorderService.findByid(id);
    }
    @RequestMapping(value = "/sellorderadd")
    public String addsellorder(@RequestParam String phone_seller,
                               @RequestParam String date,
                               @RequestParam String name,
                               @RequestParam String phone,
                               @RequestParam int id_product) {
        sellorderService.save(phone_seller, date, name, phone, id_product);
        return "Success";
    }

    @RequestMapping(value = "/sellorderall")
    public List<sellorder> querycrmorderall(@RequestParam String name) {
        return sellorderService.findAll();
    }
    @RequestMapping(value = "/sellorderbyseller")
    public List<sellorder> querycrmorderbyseller(@RequestParam String phoneseller) {
        return sellorderService.findByseller(phoneseller);
    }
}
